<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>123</div>
    <div class="box">
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
    </div>
    <script>
        let box = document.querySelector('.box')
        //封装jQuery中的children
        function children(context) {
            let ary = []
            let nodelist = context.childNodes
            for (let i = 0; i < nodelist.length; i++) {
                if (nodelist[i].nodeType == 1) {
                    ary.push(nodelist[i])
                }

            }
            return ary
        }

        //封装jQuery中的prev
        function prev(context) {
            var pre = context.previousSibling
            while (pre.nodeType !== 1) {
                pre = pre.previousSibling

            }
            return pre
        }
        console.log(prev(box));
    </script>

</body>

</html>